package icu.d4peng.basic.knife4j.properties;

import java.util.List;

import com.github.xiaoymin.knife4j.core.enums.OpenAPILanguageEnums;
import com.github.xiaoymin.knife4j.core.model.MarkdownProperty;
import icu.d4peng.basic.core.constant.ProjectConstant;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @author d4peng d4peng@qq.com
 * @date 2023-11-25 19:42:44
 */
@Data
@ConfigurationProperties(prefix = Knife4jProperties.PREFIX)
public class Knife4jProperties {

	public static final String PREFIX = ProjectConstant.PREFIX + ".knife4j";

	/**
	 * 是否开启Knife4j增强模式
	 */
	private boolean enabled = true;

	/**
	 * 是否开启默认跨域
	 */
	private boolean cors = false;

	/**
	 * 是否开启BasicHttp验证
	 */
	private Knife4jHttpBasic basic = new Knife4jHttpBasic();

	/**
	 * 是否生产环境
	 */
	private boolean production = false;

	/**
	 * 个性化配置
	 */
	private Knife4jSetting setting = new Knife4jSetting();

	/**
	 * 分组文档集合
	 */
	private List<MarkdownProperty> documents;

	@Data
	public static class Knife4jHttpBasic {

		/**
		 * basick是否开启,默认为false
		 */
		private boolean enabled = false;

		/**
		 * basic 用户名
		 */
		private String username;

		/**
		 * basic 密码
		 */
		private String password;

		/**
		 * All configured urls need to be verified by basic，Only support Regex since 4.1.0
		 */
		private List<String> include;

	}

	@Data
	public static class Knife4jSetting {

		/**
		 * Custom response HTTP status code after production environment
		 * screening(Knife4j.production=true)
		 */
		private Integer customCode = 200;

		/**
		 * i18n
		 */
		private OpenAPILanguageEnums language = OpenAPILanguageEnums.ZH_CN;

		/**
		 * Whether to display the Swagger Models function in the Ui Part.
		 */
		private boolean enableSwaggerModels = true;

		/**
		 * Rename Swagger model name,default is `Swagger Models`
		 */
		private String swaggerModelName = "Swagger Models";

		/**
		 * Whether to display the refresh variable button after each debug debugging bar,
		 * which is not displayed by default
		 */
		private boolean enableReloadCacheParameter = false;

		/**
		 * Whether the debug tab displays the afterScript function is enabled by default
		 */
		private boolean enableAfterScript = true;

		/**
		 * Whether to display the "document management" function in the Ui Part.
		 */
		private boolean enableDocumentManage = true;

		/**
		 * Whether to enable the version control of an interface in the interface. If it
		 * is enabled, the UI interface will have small blue dots after the backend
		 * changes
		 */
		private boolean enableVersion = false;

		/**
		 * Whether to enable request parameter cache
		 */
		private boolean enableRequestCache = true;

		/**
		 * For the interface request type of RequestMapping, if the parameter type is not
		 * specified, seven types of interface address parameters will be displayed by
		 * default if filtering is not performed. If this configuration is enabled, an
		 * interface address of post type will be displayed by default
		 */
		private boolean enableFilterMultipartApis = false;

		/**
		 * Filter Method type
		 */
		private String enableFilterMultipartApiMethodType = "POST";

		/**
		 * Enable host
		 */
		private boolean enableHost = false;

		/**
		 * HostAddress after enabling host
		 */
		private String enableHostText = "";

		/**
		 * Whether to enable dynamic request parameters
		 */
		private boolean enableDynamicParameter = false;

		/**
		 * Enable debug mode，default is true.
		 */
		private boolean enableDebug = true;

		/**
		 * Display bottom footer by default
		 */
		private boolean enableFooter = true;

		/**
		 * Customize footer
		 */
		private boolean enableFooterCustom = false;

		/**
		 * Custom footer content (support Markdown syntax)
		 */
		private String footerCustomContent;

		/**
		 * Show search box
		 */
		private boolean enableSearch = true;

		/**
		 * Whether to display the tab box of the original structure of OpenAPI, which is
		 * displayed by default
		 */
		private boolean enableOpenApi = true;

		/**
		 * Whether to enable home page custom configuration, false by default
		 */
		private boolean enableHomeCustom = false;

		/**
		 * Customize Markdown document content of home page
		 */
		private String homeCustomLocation;

		/**
		 * Customize Markdown document path of home page
		 */
		private String homeCustomPath;

		/**
		 * Whether to display the group drop-down box, the default is true (that is,
		 * display). In general, if it is a single group, you can set this property to
		 * false, that is, the group will not be displayed, so you don't need to select
		 * it.
		 */
		private boolean enableGroup = true;

		/**
		 * Whether to display the response status code bar
		 * https://gitee.com/xiaoym/knife4j/issues/I3TE0V
		 *
		 * @since v4.0.0
		 */
		private boolean enableResponseCode = true;

	}

}
